package com.framework.controller.yhbcontroller;

import com.framework.exception.util.RespResult;
import com.framework.service.yhbservice.YhbUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 功能描述: 用户授权
 *
 * @author ck
 * @date 2018/8/24 13:25
 */
@RestController
@Api(value="登录模块",tags={"登录模块"})
@RequestMapping("yhbLogin")
public class YhbLoginController {

	@Autowired
	private YhbUserService yhbUserService;

	/**
	 * 退出登录
	 */
	@PostMapping("user/outLogin")
	@ApiOperation("退出登录")
	public RespResult outLogin(String token) {
		yhbUserService.outLogin(token);
		return RespResult.ok();
	}
	@PostMapping("/login")
	@ApiOperation(value = "登录",notes = "用户宝登录接口",response = RespResult.class,responseContainer = "{success:true,user:user,token:token}")
	@ApiImplicitParams({
			@ApiImplicitParam(name="phone",value="手机号码",dataType="string", paramType = "query" ,required = true),
			@ApiImplicitParam(name="deptId",value="渠道id,固定值 传2",dataType="Long", paramType = "query",required = true),
			@ApiImplicitParam(name="smsCode",value="验证码",dataType="String", paramType = "query",required = true)
	})
	public RespResult loginBySms(String phone,Long deptId,String smsCode){
		Map<String,Object> map=yhbUserService.login(phone,deptId,smsCode);
		return RespResult.ok(map);
	}


}
